﻿<?PHP
function execute_XCVKSEUIXLDKVASJ($pageParent){

	// if file was uploaded
	if( isset($_POST['uploadedfile']))
	{
		customizedUpdateOption("bannerPicFileName", $_POST['uploadedfile']);
	}
	if( isset($_POST['bannerPicAltTagText']))
	{
		customizedUpdateOption("bannerPicAltTagText", $_POST['bannerPicAltTagText']);
	}
	// save thumbnail by cropping
	/*
	if( isset($_POST['xy']) )
	{
		$xy = explode(';', $_POST['xy']);
		$x=$xy[0]; $y=$xy[1]; $src_w=$xy[2]; $src_h=$xy[3];
		
		if( is_numeric($x) && is_numeric($y) && is_numeric($src_w) && is_numeric($src_h))
		{
			// make a new header thumbnail and save as next-thumbnail.jpg
			$targ_w = 960; $targ_h = 160; // $src_w/$src_h*$targ_w > 200 ? 200: $src_w/$src_h*$targ_w;
			$jpeg_quality = 90;

			$src = $templatePath."/data.pics/".$settings->title_image;
			list($width, $height) = getimagesize($src);
			
			$img_r = imagecreatefromjpeg($src);
			$dst_r = ImageCreateTrueColor( $targ_w, $targ_h );

			//imagecopyresampled($dst_r,$img_r,0,0,$x,$y,$targ_w,$targ_h,$src_w,$src_h);
			imagecopyresampled($dst_r,$img_r,0,0,$x,$y,$targ_w,$targ_w,$width,$height);

			//header('Content-type: image/jpeg');
			imagejpeg($dst_r, $templatePath."/data.pics/bannerImage.jpeg", $jpeg_quality);
		}
	}
	*/
	//print_r($_POST); print_r($_FILES);
?>
<h1>Set site banner</h1>
<h4>Expected - Width: 980px; Height: 150px</h4>
<form id="thumbnail" enctype="multipart/form-data" action="<?PHP echo get_bloginfo('wpurl'). "/wp-admin/admin.php?page=$pageParent";?>" method="post">
	Text for pic credit:<br/><textarea cols='60' name='bannerPicAltTagText'></textarea>

	<BR/>
	File url: <br/><input type="text" name="uploadedfile" style="display:inline" size='100' />
	<br/><small>Do not provide any fixed protocol (http or https), start with // instead
	<br/>
	<input class="button button-primary" type="submit" name="upload_title_image" value="Submit" style="display:inline" />
	<input class=’button-primary’ type="hidden" name="xy" value="X and Y coords"/>
	<!--
	<input type='button' class=’button-primary’ name="upload_title_image_coordinates" onclick="gatherAndFetchValues();" value="Save this crop" style="display:inline; float:right;" />
	-->
	<br /><br /><br /><br />Current banner:<br />
	<img id="bannerImageID" alt="<?PHP echo themeGetOption("bannerPicAltTagText");?>" title="<?PHP echo themeGetOption("bannerPicAltTagText");?>" src="<?PHP echo themeGetOption("bannerPicFileName");?>" style="width:100%; max-height:150px;" />
</form>
<?php
}
?>